package com.share.device.controller;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.core.web.page.TableDataInfo;
import com.share.common.security.annotation.EnableCustomConfig;
import com.share.common.security.annotation.EnableRyFeignClients;
import com.share.device.ShareDeviceApplication;
import com.share.device.domain.CabinetType;
import com.share.device.service.ICabinetTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.List;


@Tag(name = "柜机类型接口管理")
    @RestController
    //@RequestMapping("/cabinetType")
    @RequestMapping("/device/cabinetType")
    public class CabinetTypeController extends BaseController
    {
        @Autowired
        private ICabinetTypeService cabinetTypeService;


        //查询全部
        @Operation(summary = "查询全部柜机类型列表")
        @GetMapping("/getCabinetTypeList")
        public AjaxResult getCabinetTypeList()
        {
            return success(cabinetTypeService.list());
        }



        //删除
        @Operation(summary = "删除柜机类型")
        @DeleteMapping("/{ids}")
        public AjaxResult remove(@PathVariable Long[] ids)
        {
            return toAjax(cabinetTypeService.removeBatchByIds(Arrays.asList(ids)));
        }



        //修改
        @Operation(summary = "修改柜机类型")
        @PutMapping
        public AjaxResult edit(@RequestBody CabinetType cabinetType)
        {
            return toAjax(cabinetTypeService.updateById(cabinetType));
        }



        //添加
        @Operation(summary = "新增柜机类型")
        @PostMapping
        public AjaxResult add(@RequestBody CabinetType cabinetType)
        {
            return toAjax(cabinetTypeService.save(cabinetType));
        }


        //根据id查询
        @Operation(summary = "获取柜机类型详细信息")
        @GetMapping(value = "/{id}")
        public AjaxResult getInfo(@PathVariable("id") Long id)
        {
            return success(cabinetTypeService.getById(id));
        }


        /**
         * 分页查询
         */
        @Operation(summary = "查询柜机类型列表")
        @GetMapping("/list")
        public TableDataInfo list(CabinetType cabinetType)
        {
            startPage();
            List<CabinetType> list = cabinetTypeService.selectCabinetTypeList(cabinetType);
            return getDataTable(list);
        }

    }


